﻿@model  IEnumerable<DealKhuyenMaiV2.com.Models.Order>
@{
    ViewBag.Title = "AllOrder";
    Layout = "~/Views/Shared/_MemberGuestLayout.cshtml";
}



<!DOCTYPE html>
<html>
    <head>
        <link href="@Url.Content("/Content/DefaultThemes/Styles/AllOrder.css")" rel="stylesheet" type="text/css" />
        <script src="/Scripts/jquery-1.5.1.min.js" type="text/javascript"></script>
          <script src="/Scripts/jquery-ui-1.8.11.js" type="text/javascript"></script>
         
        <script type="text/javascript">
            $(function () {
                // Document.ready -> link up remove event handler
                
                $(".VoucherUpdate").click(function () {
                    // Get the id from the link
                    var orderid = $(this).attr("data-id");
                    $.post("/Company/UpdateVoucher", { "id": orderid },
                        function (data) {

                          
                            $(".vou-" + orderid).text("Rồi");
                        });
                });

            });


   
        </script>
    </head>

    <body>
        <div class="body-left">
            <!--Unknown-->
            <!-- UPD 27.10.3 -->
            <div class="middle-box-white">
                <div class="middle-box-title">
                    <div class="left">
                        <h3>
                            <span class="middle-size">Danh sách các đơn hàng</span>
                        </h3>
                    </div>
                    <div class="clear"></div>
                </div>
               
                <div class="middle-box-content">
                    <h3>
                        <span>
                            <a>Deal: </a>@ViewBag.dealname<br/>
                            <a>Bắt đầu: </a>@ViewBag.Date_Start<br/>
                            <a>Kết thúc: </a>@ViewBag.Date_End<br/>
                            <br/>
                            <a>Tổng số đơn: </a>@Model.Count()<br/>
                            <a>Tổng số tiền: </a>@ViewBag.total.000 đồng
                        </span>
                    </h3>
                    <h3>Danh sách các đơn đặt hàng:</h3>
                    
                    <!--Table for List Order-->
                    <div class="order">
                        <div class="table_order">
                            <table class="table_title">
                                <tbody>
                                    <tr>
                                        <td class="order_name">
                                            <div id = "realloxer" class="title"><span>Mã đơn hàng</span></div>
                                        </td>
                                        <td class="order_account">
                                            <div class="title"><span>Tài khoản</span></div>
                                        </td>
                                        <td class="order_buy_at">
                                            <div class="title"><span>Mua lúc</span></div>
                                        </td>
                                        <td class="order_price">
                                            <div class="title"><span>Thành tiền</span></div>
                                        </td>
                                        <td class="order_voucher">
                                            <div class="title"><span>Voucher</span></div>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                            <div >
                                <table class="table_content">
                                    <tbody>
                                        @foreach (var order in Model)
                                        {
                                            <tr>
                                            
                                                <td class="order_name">
                                                    <div class="content">
                                                        @order.IDOrder
                                                    </div>
                                                </td>
                                                
                                                <td class="order_account">
                                                    <div class="content">
                                                        @order.Account.Email
                                                    </div>
                                                </td>
                                                
                                                <td class="order_buy_at">
                                                    <div class="content">
                                                        @order.DateAdded
                                                    </div>
                                                </td>
                                                
                                                <td class="order_price">
                                                    <div class="content">
                                                        @Decimal.Round(@order.Total, 3)
                                                    </div>
                                                </td>
                                                
                                                <td class="order_voucher"> @*class="vou-" + "@order.IDOrder">*@
                                                    <div class="vou-@order.IDOrder">
                                                        @if (@order.Voucher == true)
                                                        {
                                                            <div>Rôi</div>
                                                        }
                                                        else
                                                        {
                                                            <div>
                                                                <input type="submit" class="VoucherUpdate" data-id="@order.IDOrder" value="Cập nhật">
                                                            </div>
                                                        }
                                                    </div>
                                                </td>
                                            
                                            </tr>
                                        }
                                    </tbody>
                                    
                                </table>
                            </div>
                        </div>
                    </div>
                    <!--End table for List Order-->
                </div>
            </div>
        </div>
    </body>
</html>